package part2;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * Main1Write
 *  - Write an entire object to a file
 * @author tony
 *
 */

public class Main1WriteObject {
	public static void main(String[] args) {
		final String OUTPUTFILENAME = "output.obj";
		Data d1 = new Data( 10, "Hello" );
		System.out.println( "In this program we will write an object to the file " + OUTPUTFILENAME );
		try {
			FileOutputStream fo = new FileOutputStream( OUTPUTFILENAME );
			ObjectOutputStream oos = new ObjectOutputStream(fo);
			oos.writeObject(d1);
			oos.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println("OK, done - refresh your project to see the file.");
	}
}
